import Vec3 from "../../common/vec3";
import CONSTANT from '../../constant';
import Method from "../../common/method";

export default class JointConfig {
    constructor() {
        this.rigidBody1 = null;
        this.rigidBody2 = null;
        this.localAnchor1 = new Vec3();
        this.localAnchor2 = new Vec3();
        this.allowCollision = false;
        this.solverType = CONSTANT.SETTING_DEFAULT_JOINT_CONSTRAINT_SOLVER_TYPE;
        this.positionCorrectionAlgorithm = CONSTANT.SETTING_DEFAULT_JOINT_POSITION_CORRECTION_ALGORITHM;
        this.breakForce = 0;
        this.breakTorque = 0;
    }
    _init(rb1,rb2,_worldAnchor) {
        let worldAnchor=_worldAnchor.elements;
        this.rigidBody1 = rb1;
        this.rigidBody2 = rb2;
        let tf1 = this.rigidBody1._transform.elements, localPoint = this.localAnchor1.elements;
        Method.inverseTransformVec3(tf1,worldAnchor,0,localPoint);
        let tf2 = this.rigidBody2._transform.elements, localPoint1 = this.localAnchor2.elements;
        Method.inverseTransformVec3(tf2,worldAnchor,0,localPoint1);
    }
}